#include <stdio.h>
#include <stdlib.h>

int filter_ansi(char *gbk_string)
{
    int ansi_anlnum = 0;
    char *str = gbk_string, *next = gbk_string+1;

    if (gbk_string == NULL)
        return ansi_anlnum;

    while (*str != '\0') {
        while (isalnum(*str)) {
            *str = *(next++);
            ansi_anlnum ++;
        }
        *(++str) = *(next++); 

        if (*str < 0)
            *(++str) = *(next++); 
    }

    return ansi_anlnum;
}

int main(int argc, char *argv[])
{
    char gbk_string[] = "a1我是b2是c3A谁";
    printf("original string is %s\n", gbk_string);
    printf("find ansi_alnum %d\n", filter_ansi(gbk_string));
    printf("now string is %s\n", gbk_string);
    return 0;
}
